import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.invoke.VarHandle;
import java.util.Map;

@WebServlet("/a")
public class ServletDemo2 extends HttpServlet {


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取一个请求参数
        String username = request.getParameter("username");
        System.out.println("username = " + username);
        String psaaworld = request.getParameter("psaaworld");
        System.out.println("psaaworld = " + psaaworld);
        //获取一组参数hobby
        String[] hobbies = request.getParameterValues("hobby");
        System.out.println("hobbies = " + hobbies);
        //获取所有请求参数map
        Map<String, String[]> map = request.getParameterMap();
        for (String keys: map.keySet()) {
            String[] values = map.get(keys);
            for (String value : values) {
                System.out.println(value);
            }
        }

    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
